#!/usr/bin/env python
# -*- coding: utf-8 -*-
# title       :
# author      : jarry
import os

from JTK.jcore.JPath import JPath
from .InitQtModule import *
from . import QColorScheme as qcs
from . import AovListWidget
# reload(AovListWidget)
# from unipath import Path


from . import __file__ as _initpy_file
__CURRENT_PATH__ = os.path.dirname(os.path.realpath(_initpy_file))


class AOVActiveItemWidget(QWidget):
    addClicked = Signal(object)
    removeClicked = Signal(object)
    LABEL = ''
    scheme = qcs.QColorScheme

    def __init__(self, parent=None, project=''):
        super(AOVActiveItemWidget, self).__init__(parent)
        # self.setMinimumWidth(60)
        self.setObjectName('AOVActiveItemWidget')
        main_layout = QVBoxLayout()
        main_layout.setSpacing(5)
        main_layout.setContentsMargins(0, 0, 0, 0)
        label_layout = QHBoxLayout()
        self._label = self.LABEL
        label = QLabel('Active AOVs - ' + self._label)
        del_button = QToolButton()
        # del_button.setText('del')
        icon_path = JPath(__CURRENT_PATH__).parent.child('data').child('icons').child('del.png')
        del_button.setIcon(QIcon(icon_path))
        del_button.setStyleSheet('background-color: transparent;border-width: 0px;')
        label_layout.addWidget(label)
        label_layout.addWidget(del_button)
        self.list_widget = AovListWidget.AovListWidget(self)

        button_layout = QHBoxLayout()
        self.add_button = QPushButton('>>')
        self.remove_button = QPushButton('<<')
        self.group_button = QPushButton('+LG')

        button_layout.addWidget(self.add_button)
        button_layout.addWidget(self.remove_button)
        button_layout.addWidget(self.group_button)

        check_layout = QHBoxLayout()
        self.merge_cbx = QCheckBox('Merge')
        self.half_cbx = QCheckBox('Half')
        self.prefix_cbx = QCheckBox('Prefix')

        check_layout.addWidget(self.merge_cbx)
        check_layout.addWidget(self.half_cbx)
        check_layout.addWidget(self.prefix_cbx)

        group_layout = QHBoxLayout()
        group_label = QLabel('GroupName')
        self.group_edit = QLineEdit()
        group_layout.addWidget(group_label)
        group_layout.addWidget(self.group_edit)

        main_layout.addLayout(label_layout)
        main_layout.addWidget(self.list_widget)
        main_layout.addLayout(button_layout)
        main_layout.addLayout(check_layout)
        main_layout.addLayout(group_layout)

        self.setLayout(main_layout)
        del_button.clicked.connect(self.deleteLater)
        # self.add_button.connect.clicked(self.clicked2)
        self.removeClicked.emit(self.remove_button)

        # style
        scheme = self.scheme()
        scheme.setColor(QColor(180, 150, 0, 255), highlightColor=QColor(250, 250, 250), spread=5.5)
        scheme.applyStyle(self.group_button)

if __name__ == "__main__":
    app = QApplication([])
    my_ui = AOVActiveItemWidget()
    my_ui.show()
    app.exec_()
